﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

#endregion

using System;

namespace ScrumTable.Common.Collections
{
    /// <summary>
    /// Gets a pair of two value instances.
    /// </summary>
    [Serializable]
    public class SerializablePair<TLeft, TRight> : Pair<TLeft, TRight>
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the left value associated with the pair.
        /// </summary>
        public override TLeft Left
        {
            get { return LeftInternal; }
            set { LeftInternal = value; }
        }

        /// <summary>
        /// Gets the right value associated with the pair.
        /// </summary>
        public override TRight Right
        {
            get { return RightInternal; }
            set { RightInternal = value; }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new Pair instance.
        /// </summary>
        public SerializablePair() : base(default(TLeft), default(TRight))
        {   
        }

        /// <summary>
        /// Creates a new Pair instance.
        /// </summary>
        public SerializablePair(TLeft left, TRight right) : base(left, right)
        {
        }

        #endregion


        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Implements the operator ==.
        /// </summary>
        /// <param name="left">Specifies the left object.</param>
        /// <param name="right">Specifies the right object.</param>
        /// <returns>The result of the operator.</returns>
        public static bool operator ==(SerializablePair<TLeft, TRight> left, SerializablePair<TLeft, TRight> right)
        {
            return (((Pair<TLeft, TRight>)left) == right); // force compiler to use Pair<TLeft,TRight>::operator==()
        }

        /// <summary>
        /// Implements the operator !=.
        /// </summary>
        /// <param name="left">Specifies the left object.</param>
        /// <param name="right">Specifies the right object.</param>
        /// <returns>The result of the operator.</returns>
        public static bool operator !=(SerializablePair<TLeft, TRight> left, SerializablePair<TLeft, TRight> right)
        {
            return !(left == right);
        }

        /// <summary>
        /// Determines whether the specified IDataObject is equal to the current object.
        /// </summary>
        /// <param name="toCompare">Parameter to check.</param>
        /// <returns>Returns true if the objects are equal.</returns>
        public override bool Equals(object toCompare)
        {
            return Equals(toCompare as SerializablePair<TLeft, TRight>);
        }

        /// <summary>
        /// Returns the hash code for this IDataObject.
        /// </summary>
        /// <returns>Returns the computed hash value.</returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
